#!/usr/bin/python
# -*- coding: utf-8 -*-



import os
import sys
import re
from PyQt4 import QtCore, QtGui
from  Main import *
class Page8(object):
    def __init__(self,session):
		self.session=session
		self.app = QtGui.QApplication(sys.argv)
		self.window=QtGui.QDialog()
                self.retour=0
                self.parametre={}
                self.config={}
                self.nbMesure=0
                self.dicocampagne={}


    def suivant(self):

    

       self.window.close()
       
       obj9=Main()
       obj9.func9(self.config)
      
   
      
             

    def affich(self,param):
        
	self.setupUi(self.window)
	self.window.show()
        sys.exit(self.app.exec_())
    def precedent(self):
        self.window.close()
        os.system("./Main.py 7")
    def nouvelleCampagne(self):
        self.window.close()
        os.system("./Main.py 5")

    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(1270, 721)
        self.lineEdit_campagne_terminee = QtGui.QLineEdit(Dialog)
        self.lineEdit_campagne_terminee.setGeometry(QtCore.QRect(290, 20, 691, 66))
        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(32)
        font.setWeight(50)
        font.setBold(False)
        self.lineEdit_campagne_terminee.setFont(font)
        self.lineEdit_campagne_terminee.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_campagne_terminee.setReadOnly(True)
        self.lineEdit_campagne_terminee.setObjectName("lineEdit_campagne_terminee")
        self.lineEdit_nom_campagne = QtGui.QLineEdit(Dialog)
        self.lineEdit_nom_campagne.setGeometry(QtCore.QRect(20, 130, 301, 41))
        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(14)
        self.lineEdit_nom_campagne.setFont(font)
        self.lineEdit_nom_campagne.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_nom_campagne.setReadOnly(True)
        self.lineEdit_nom_campagne.setObjectName("lineEdit_nom_campagne")
        self.lineEdit_nom_campagne_vide = QtGui.QLineEdit(Dialog)
        self.lineEdit_nom_campagne_vide.setGeometry(QtCore.QRect(320, 130, 891, 41))
        expr2=re.compile('[A-Za-z]')        
        fichier=open('dicocampagne','r')
        for line in fichier.readlines():
            if expr2.findall(line):
                self.dicocampagne[line.split(':')[0].split('\n')[0]]=line.split(':')[1].split('\n')[0]
        fichier.close()
        self.lineEdit_nom_campagne_vide.setText(self.dicocampagne["nom"])
        self.lineEdit_nom_campagne_vide.setReadOnly(True)
        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(14)
        self.lineEdit_nom_campagne_vide.setFont(font)
        self.lineEdit_nom_campagne_vide.setObjectName("lineEdit_nom_campagne_vide")
        self.lineEdit_resultat_campagne = QtGui.QLineEdit(Dialog)
        self.lineEdit_resultat_campagne.setGeometry(QtCore.QRect(20, 270, 371, 41))
        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(14)
        self.lineEdit_resultat_campagne.setFont(font)
        self.lineEdit_resultat_campagne.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_resultat_campagne.setReadOnly(True)
        self.lineEdit_resultat_campagne.setObjectName("lineEdit_resultat_campagne")
        self.pushButton_suivant = QtGui.QPushButton(Dialog)
        self.pushButton_suivant.setGeometry(QtCore.QRect(1070, 650, 171, 41))
        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(12)
        self.pushButton_suivant.setFont(font)
        self.pushButton_suivant.setObjectName("pushButton_suivant")
        self.pushButton_annuler = QtGui.QPushButton(Dialog)
        self.pushButton_annuler.setGeometry(QtCore.QRect(730, 650, 171, 41))
        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(12)
        self.pushButton_annuler.setFont(font)
        self.pushButton_annuler.setObjectName("pushButton_annuler")
        self.pushButton_precedent = QtGui.QPushButton(Dialog)
        self.pushButton_precedent.setGeometry(QtCore.QRect(900, 650, 171, 41))
        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(12)
        self.pushButton_precedent.setFont(font)
        self.pushButton_precedent.setObjectName("pushButton_precedent")
        self.lineEdit_nombre_mesures = QtGui.QLineEdit(Dialog)
        self.lineEdit_nombre_mesures.setGeometry(QtCore.QRect(20, 200, 291, 41))
        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(14)
        self.lineEdit_nombre_mesures.setFont(font)
        self.lineEdit_nombre_mesures.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_nombre_mesures.setReadOnly(True)
        self.lineEdit_nombre_mesures.setObjectName("lineEdit_nombre_mesures")
        self.lineEdit_nombre_mesures_vide = QtGui.QLineEdit(Dialog)
        self.lineEdit_nombre_mesures_vide.setGeometry(QtCore.QRect(310, 200, 61, 41))
        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(14)
        self.lineEdit_nombre_mesures_vide.setFont(font)
        self.lineEdit_nombre_mesures_vide.setObjectName("lineEdit_nombre_mesures_vide")
        expr=re.compile('[0-9]')        
        fichier=open('nbMesure','r')
        for line in fichier.readlines():
            if expr.findall(line):
                self.nbMesure=line.split('\n')[0]
        fichier.close()


        
        self.lineEdit_nombre_mesures_vide.setText(str(self.nbMesure))
        self.lineEdit_nombre_mesures_vide.setReadOnly(True)
        self.textEdit_resultat_campagne_vide = QtGui.QTextEdit(Dialog)
        self.textEdit_resultat_campagne_vide.setGeometry(QtCore.QRect(20, 310, 1191, 301))
        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(12)
        self.textEdit_resultat_campagne_vide.setFont(font)
        self.textEdit_resultat_campagne_vide.setObjectName("textEdit_resultat_campagne_vide")
        self.pushButton_Nouvelle_Campagne = QtGui.QPushButton(Dialog)
        self.pushButton_Nouvelle_Campagne.setGeometry(QtCore.QRect(490, 650, 241, 41))
        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(12)
        self.pushButton_Nouvelle_Campagne.setFont(font)
        self.pushButton_Nouvelle_Campagne.setObjectName("pushButton_Nouvelle_Campagne")

        self.retranslateUi(Dialog)
        QtCore.QObject.connect(self.pushButton_Nouvelle_Campagne, QtCore.SIGNAL("clicked()"), self.nouvelleCampagne)
        QtCore.QObject.connect(self.pushButton_annuler, QtCore.SIGNAL("clicked()"), Dialog.accept)
        QtCore.QObject.connect(self.pushButton_precedent, QtCore.SIGNAL("clicked()"),self.precedent)
        QtCore.QObject.connect(self.pushButton_suivant, QtCore.SIGNAL("clicked()"), self.suivant)
        QtCore.QMetaObject.connectSlotsByName(Dialog)

    def retranslateUi(self, Dialog):
        Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
        self.lineEdit_campagne_terminee.setText(QtGui.QApplication.translate("Dialog", "CAMPAGNE TERMINEE", None, QtGui.QApplication.UnicodeUTF8))
        self.lineEdit_nom_campagne.setText(QtGui.QApplication.translate("Dialog", "Nom de la campagne :", None, QtGui.QApplication.UnicodeUTF8))
        self.lineEdit_resultat_campagne.setText(QtGui.QApplication.translate("Dialog", "Résultats de la campagne :", None, QtGui.QApplication.UnicodeUTF8))
        self.pushButton_suivant.setText(QtGui.QApplication.translate("Dialog", "Suivant >>", None, QtGui.QApplication.UnicodeUTF8))
        self.pushButton_annuler.setText(QtGui.QApplication.translate("Dialog", "Annuler", None, QtGui.QApplication.UnicodeUTF8))
        self.pushButton_precedent.setText(QtGui.QApplication.translate("Dialog", "<< Précédent", None, QtGui.QApplication.UnicodeUTF8))
        self.lineEdit_nombre_mesures.setText(QtGui.QApplication.translate("Dialog", "Nombre de mesures :", None, QtGui.QApplication.UnicodeUTF8))
        self.pushButton_Nouvelle_Campagne.setText(QtGui.QApplication.translate("Dialog", "Nouvelle campagne", None, QtGui.QApplication.UnicodeUTF8))

